const webpackBase = require('./webpack.config.base.js');
const path=require('path');
const webpackMerge = require('webpack-merge');
const webpack=require('webpack');
const config = require('./index');
const AddAssetHtmlPlugin = require('add-asset-html-webpack-plugin');
module.exports = webpackMerge(webpackBase,{
    module:{
        rules:[
            {
                test: /\.(less|css)$/,
                exclude: /node_modules/,
                loader: ['style-loader', 'css-loader', 'less-loader'] 
            },               
        ]
    }, 	
	devServer:{
		open: true,
		contentBase:"./dist",
		historyApiFallback: {
		  rewrites: [
		    { from: /^\/$/, to: '/home/index.html' },
		    { from: /^\/admin/, to: '/admin/index.html' },
		  ]
		},
		watchContentBase: true,
		hot: true,
        inline:true,
        port:8083,
        overlay:{ 
            errors:true,
            warnings:true
        },
	    proxy: {
	      '/api': {
	        target: 'http://localhost:8089',
	        changeOrigin: true,
	        pathRewrite: {
	          '^/api': ''
	        }
	      }
	    }        
    },
    plugins:[ 
    	new webpack.HashedModuleIdsPlugin(),
        new webpack.DllReferencePlugin({
          context: __dirname,          
          manifest: require('../manifest.json'),
          name:'manifest_library'
        }),    
    	new AddAssetHtmlPlugin({ filepath: require.resolve('../manifest.js'), includeSourcemap: false }),
    	new webpack.HotModuleReplacementPlugin()
    ]
});